package inc.zhugastrov.sellerform;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class WherehousePane extends JPanel {
	private JTable catalog;
	private ItemsTableModel model = new ItemsTableModel();
	private JScrollPane scrollPane;
	private static WherehousePane instance;
	
	public static WherehousePane getInstance() {
		if (instance == null)
			instance = new WherehousePane();
		return instance;
	}
	
	public void addToWherehouse(Product product) {
		model.addRow(product);
	}
	
	private WherehousePane() {
		init();
	}
	
	private void init() {
		catalog = new JTable();
		catalog.setModel(model);
		catalog.getTableHeader().setReorderingAllowed(false);
		catalog.setFocusable(false);
		catalog.setSelectionMode(0);
		scrollPane = new JScrollPane(catalog);
		catalog.setPreferredScrollableViewportSize(new java.awt.Dimension(500,
				300));
		add(scrollPane);
	}
}
